package com.config;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;


public class ConditionConfig implements Condition {
    /**
     *
     * @param conditionContext 获取当前上下文
     * @param annotatedTypeMetadata 获取当前注解的信息
     */
    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
        // 获取当前系统环境
        Environment environment = conditionContext.getEnvironment();
        String osName = environment.getProperty("os.name");
        if(osName.equals("Windows 10")){
            // 注册
            return true;
        }
        // 不进行注册
        return false;
    }
}
